import os
import time
import django

from django.core.cache import cache

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myfirstproj.settings')
django.setup()


def basic_use():
    s = 'Hello World, Hello Django Cache.'
    cache.set('key', s)
    cache_result = cache.get('key')
    print(cache_result)
    s2 = 'Hello World, Hello Django Timeout Cache.'
    cache.set('key2', s2, 5)
    cache_result = cache.get('key2')
    print(cache_result)
    # time.sleep(5)
    # cache_result = cache.get('key2')
    # print(cache_result)
    # pass

def get2():
    time.sleep(5)
    res = cache.get('可乐')
    print('res',res)
if __name__ == '__main__':
    # basic_use()
    # get2()
    cache.set('可乐','百事可乐',5)
    print('begin...')
    print(cache.get('可乐'))

    get2()